package net.entelijan.config.impl2;

import java.util.List;

import javax.swing.JToggleButton;

import net.entelijan.cobean.core.ICobean;
import net.entelijan.cobean.toggle.DefaultToggleInitializer;

public class DefaultToggleInitializerBinderFactory extends
		AbstractBinderFactory {

	public DefaultToggleInitializerBinderFactory() {
		super();
	}

	protected boolean isCoreComponent(IEnhancedComponent comp) {
		return comp.getComponent() instanceof JToggleButton;
	}

	protected List<List<String>> adjustPathesOfCoreComponent(
			List<List<String>> pathes) {
		return PathUtil.removeSuffixesIgnoreCase(pathes, "ToggleButton",
				"CheckBox", "RadioButton");
	}

	protected ICobean<Boolean> createCobean(final IEnhancedComponent coreComp,
			final List<IEnhancedComponent> allComps, Class<?> modelType,
			Object config) {
		JToggleButton core = (JToggleButton) coreComp.getComponent();
		DefaultToggleInitializer ini = new DefaultToggleInitializer();
		ini.setCoToggleButton(core);
		return ini.initialize();
	}

}
